//
//  MHShareDataBlock.m
//  UI_18_KVO2
//
//  Created by 马欢 on 15/12/23.
//  Copyright © 2015年 蓝鸥. All rights reserved.
//

#import "MHShareDataBlock.h"

@implementation MHShareDataBlock
//GET 异步
+(void)GETAsynchronousBlockWithURL:(NSString *)urlString PassBlock:(MhShareDataBlock)PassBlock{

NSURL *url = [NSURL URLWithString:urlString];
//    2.创建对话session
NSURLSession *session = [NSURLSession sharedSession];
//    3.创建task()(内部处理了请求，默认就是一个get ,直接传Url就行)
NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
    //        返回主线程
    dispatch_sync(dispatch_get_main_queue(), ^{
        //利用passBlock传值
        PassBlock(data);
    });
}];
//    7.启动
[dataTask resume];
}
@end
